package com.zrrd.yunchmall.config;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Liangyaoyun
 */
@SuppressWarnings("all")
@Component
public class RequestOriginParserDefinition implements RequestOriginParser {
    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {
        //1.serviceName可以改变,改为任意参数名字都可以
        //2.必须是请求参数吗？不是,请求头的值也可以做授权规则限制，如Token
        //httpServletRequest.getHeader("token");

        return httpServletRequest.getParameter("serviceName");
    }
}
